package com.siki.vo;

import com.siki.pojo.model.DepartmentInformation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * @Author Siki
 * @Date 2020/4/26
 */
@ApiModel("志愿信息列表返回VO")
@Getter
@Setter
@NoArgsConstructor
public class UserIntentionListVO {

    @ApiModelProperty("次序")
    Integer no;

    @ApiModelProperty("意愿部门名称")
    String departmentInfo;

    @ApiModelProperty("意愿部门名称")
    String post;

    @ApiModelProperty("部门审核状态")
    String resultType;

    public UserIntentionListVO(DepartmentInformation departmentInformation) {
        Optional.ofNullable(departmentInformation).ifPresent(departmentInformations -> {
            this.no = departmentInformations.getNo();
            this.departmentInfo = departmentInformations.getDepartmentInfo();
            this.post = departmentInformations.getPost();
            this.resultType = departmentInformations.getResultType().toString();
        });
    }

    public static List<UserIntentionListVO> getList(List<DepartmentInformation> departmentInformations) {
        List<UserIntentionListVO> userIntentionVOS = new ArrayList<>();
        for (DepartmentInformation di :
                departmentInformations) {
            userIntentionVOS.add(new UserIntentionListVO(di));
        }
        return userIntentionVOS;
    }
}
